﻿
/**
* 命名空间: Game.TDBehaviorTree
*
* 功 能： N/A
* 类 名： NodeCombine 组合节点
*
* Ver 变更日期 负责人 变更内容
* ───────────────────────────────────
* V0.01 2019/12/11 14:56:57  
*/




using Newtonsoft.Json;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace Game.TDBehaviorTree
{

   [System.Serializable]
    /// <summary>
    /// 组合节点
    /// </summary>
    public  class NodeCombine:NodeBase
    {
       
        //子节点
        [JsonProperty("childNodes")]
        public List<NodeBase> m_childNodes = new List<NodeBase>();


        public NodeCombine(NodeType _type) : base(_type)
        {

        }

        /// <summary>
        /// 添加子节点
        /// </summary>
        /// <param name="_node">node</param>
        public void AddNode(NodeBase _node)
        {
            int count = m_childNodes.Count;
            _node.NodeIndex = count;
            m_childNodes.Add(_node);
        }


        public override void DeRializable(NodeValue _value)
        {
            base.DeRializable(_value);
            for (int i = 0; i < _value.m_m_ChildListIndex.Count; i++)
            {
                NodeBase _node = _value.m_AllNodeValue[_value.m_m_ChildListIndex[i]].m_NodeBase;
                _node.NodeIndex = i;
                m_childNodes.Add(_node);
            }
           
        }
    }
}
